# Contributor: Bjoern Schilberg <bjoern@intevation.de>
# Maintainer: Bjoern Schilberg <bjoern@intevation.de>
pkgname=mapserver
pkgver=8.0.1
pkgrel=3
pkgdesc="CGI-based platform for publishing spatial data and interactive mapping applications to the web"
url="https://mapserver.org/"
# s390x: blocked by exempi-dev
arch="all !s390x"
license="MIT"
depends_dev="
	cairo-dev
	curl-dev
	exempi-dev
	fcgi-dev
	freetype-dev
	fribidi-dev
	gdal-dev
	geos-dev
	giflib-dev
	harfbuzz-dev
	jpeg-dev
	libpq-dev
	librsvg-dev
	libxml2-dev
	pixman-dev
	proj-dev
	protobuf-c-dev
	"
makedepends="
	$depends_dev
	cmake
	samurai
	"
subpackages="
	$pkgname-dev
	"
source="
	https://download.osgeo.org/mapserver/mapserver-$pkgver.tar.gz
	10-musl.patch
	20-libxml.patch
	"

build() {
	CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DWITH_GEOS=ON \
		-DWITH_POSTGIS=ON \
		-DWITH_KML=ON \
		-DWITH_WCS=ON \
		-DWITH_SOS=ON \
		-DWITH_WMS=ON \
		-DWITH_CLIENT_WMS=ON \
		-DWITH_WFS=ON \
		-DWITH_CLIENT_WFS=ON \
		-DWITH_THREAD_SAFETY=OFF \
		-DWITH_FCGI=ON \
		-DWITH_CAIRO=ON \
		-DWITH_RSVG=ON \
		-DWITH_CURL=ON \
		-DWITH_MYSQL=OFF \
		-DWITH_FRIBIDI=ON \
		-DWITH_HARFBUZZ=ON \
		-DWITH_EXEMPI=ON \
		-DWITH_PROTOBUFC=ON \
		-DWITH_PIXMAN=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	# shellcheck disable=2115
	rm -rf "$pkgdir"/usr/share/
	chmod -x "$pkgdir"/usr/include/mapserver/*.h
}

sha512sums="
dae14a7eb6b09f5461c19bff83ca8ed6c21ae84d451b2c854794efb25b144b7edbf2a33479dc53e78aa646e5196e81219b4a1f393ff824db4508204a2d0301d1  mapserver-8.0.1.tar.gz
12743afabee45bc77788b699cfc8ac50cf11629e0041b7b9aac3ba1c966d14fa0280044b72ac1b7520e99124d9b4627a6b5d005a486ae9ad03bc86b0775ad547  10-musl.patch
e48aeabe8e96b8fb20006672812441218c7b8ff7f765e03c36a5a6a1a8196b847df8d8d18b9164d090cf574a9c7226e4512686773345686be2f0b2819aa4a50a  20-libxml.patch
"
